package cglgu.trellis.chado.das2.modelimpl;

/*
 * $Id: ChadoSourcesCapabilityFactory.java 191 2011-03-27 00:38:22Z sundaram.georgetown@gmail.com $
 * $Author: sundaram.georgetown@gmail.com $
 * $Date: 2011-03-27 00:38:22 +0000 (Sun, 27 Mar 2011) $
 * $Rev: 191 $
 * $HeadURL: http://genomancer.googlecode.com/svn/branches/gu-dev-branch/tengcha/src/cglgu/trellis/chado/das2/modelimpl/ChadoSourcesCapabilityFactory.java $
 */

import cglgu.trellis.chado.das2.modelimpl.gbol.ChadoSourcesCapability;
import cglgu.trellis.chado.das2.modelimpl.cglgu.ChadoSourcesCapability;
import cglgu.trellis.chado.das2.modelimpl.ChadoSourcesCapability;

public class ChadoSourcesCapabilityFactory  {

	private static ChadoSourcesCapability instance = null;

	protected ChadoSourcesCapabilityFactory() {

	}

	public static ChadoSourcesCapabilityFactory getInstance(){

		if (instance == null){
			instance = new ChadoSourcesCapabilityFactory();
		}

		return instance;
	}

	public static ChadoSourcesCapability create(String type, URI base_uri, String query_uri, Map<String,String> params){

		cglgu.trellis.chado.das2.modelimpl.ChadoSourcesCapability cap;

		if (type == null){
			/* This will be the default ChadoSourcesCapability.
			 * The corresponding modelimpl classes will expect CglguDbUtil
			 * to return JDBC ResultSet objects.
			 */
			cap = new cglgu.trellis.chado.das2.modelimpl.ChadoSourcesCapability(base_uri, query_uri, params);
		}
		else if (type.toLowerCase().equals("cglgu")){
			/* The corresponding modelimpl classes will expect CglguDbUtil
			 * to return lightweight, intermediate objects like
			 * Analysis and Chromosome.
			 */
			cap = new cglgu.trellis.chado.das2.modelimpl.cglgu.ChadoSourcesCapability(base_uri, query_uri, params);
		}
		else if (type.toLowerCase().equals("gbol")){
			/* The corresponding modelimpl classes will expect
			 * CglguDbUtil to return GBOL objects.
			 */
			cap = new cglgu.trellis.chado.das2.modelimpl.gbol.ChadoSourcesCapability(base_uri, query_uri, params);
		}
		else {
			System.err.println("Unsupport ChadoSourcesCapability type " + type);
			System.exit(1);
		}
	}
}